﻿@{
    ViewBag.Title = "模块权限";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Assets/global/Plugins/jquery-1.11.0.min.js"></script>
@section scripts{
    <script src="~/Assets/global/Plugins/jsTree/dist/jstree.js"></script>
    <script>
        $(
        function () {
            $.ajax({
                url: "/Authority/GetAllModulesWithRole/@ViewBag.RoleId",
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#module_tree").jstree({
                    "core": {
                        'data': data
                    },
                    "plugins": ["checkbox", "sort", "search"]
                });
                $('#module_tree').on("changed.jstree", function (e, data) {
                    $('#moduleIds').val($('#module_tree').jstree(true).get_bottom_selected(false));
                });

            },
        });

        $('#module_tree').on("ready.jstree", function (e, data) {
            $('#module_tree').jstree('close_all');
        });
        var to = false;
        $('#query').keyup(function () {
            if (to) { clearTimeout(to); }
            to = setTimeout(function () {
                var v = $('#query').val();
                $('#module_tree').jstree(true).search(v);
            }, 250);
        });
    }
    )
    </script>
}

<h3 class="page-title">
    权限管理 <small>模块管理</small>
</h3>
<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <i class="fa fa-home"></i>
            <a href="index.html">首页</a>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <a href="@Url.Action("Index", "Authority")">权限管理</a>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <a href="#">管理</a>
        </li>
    </ul>
    <div class="page-toolbar">
        <div class="btn-group pull-right">
        </div>
    </div>
</div>
<div class="portlet box purple">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-cogs"></i>
        </div>
        <div class="tools">
            <a href="javascript:;" class="collapse"></a>
        </div>
        <div class="actions">
            <a class="btn green" href="@Url.Action("Index", new { RoleCode = Request.QueryString["RoleCode"], RoleName = @Request.QueryString["RoleName"] })"><i class="fa  fa-mail-reply"></i>返回</a>
        </div>
    </div>
    <div class="portlet-body form">

        <form id="menuCreate" action="@Url.Action("UpdateRoleModuleRelationship")" method="post" class="form-horizontal">
            <div class="form-body">
                <input type="hidden" value="@ViewBag.RoleId" id="roleId" name="roleId" />
                <div class="form-group">
                    <label class="col-md-3 control-label">角色名称&nbsp;&nbsp;</label>
                    <div class="col-md-4">
                        <input type="text" id="roleName" name="roleName" class="form-control" readonly="readonly" value="@Request.QueryString["DispRoleName"]">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="row">
                        <label class="col-md-3 control-label">角色权限操作&nbsp;&nbsp;</label>
                        <div class="col-md-4">
                            <input type="text" id="query" class="form-control" placeholder="组织搜索条件">
                            <input type="hidden" id="moduleIds" value="" name="moduleIds" />
                        </div>
                    </div>
                    <div class="col-md-3"></div>
                    <div id="module_tree" class="col-md-4">
                    </div>
                </div>
                @* <div class="row">*@
            </div>
            <div class="form-actions"><div class="col-md-offset-3 col-md-9">
                    <button type="submit" class="btn red">确定</button>
                    <a href="@Url.Action("Index", new { RoleCode = Request.QueryString["RoleCode"], RoleName = @Request.QueryString["RoleName"] })" class="btn default">取消</a>
                </div>
                @* </div>*@
            </div>
        </form>

    </div>
</div>
